#include <stdio.h>
#include <stdlib.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <assert.h>

static void read_mission(const char *path)
{
	xmlDocPtr doc = NULL;
	xmlNodePtr robot, control;

	doc = xmlParseFile(path);
	assert( doc != NULL );

	for (robot = doc->children; robot != NULL; robot = robot->next ) {
		printf("%s : address = %s\n", robot->name,
					xmlGetProp(robot, "address"));
		for (control = robot->children; control != NULL; 
			control = control->next ) {
			printf("\t%s\n", control->name);
		}
	}

	xmlFreeDoc(doc);
}

int main(int argc, char *argv[])
{
	if ( argc < 2 ) {
		printf("Usage: %s <path>\n", argv[0]);
		exit(EXIT_SUCCESS); 
	} 

	read_mission(argv[1]);
	xmlCleanupParser();
	xmlMemoryDump();

	exit(EXIT_SUCCESS);
}
